package com.hschinese.pronunciation.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
//import com.tendcloud.tenddata.TCAgent;

import com.hschinese.pronunciation.R;
import com.jaeger.library.StatusBarUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 基础父类
 */
@SuppressLint("SimpleDateFormat")
public class BaseActivity extends AppCompatActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		MyApplication.getInstance().pushAty(this);
	}
	@Override
	public void setContentView(int layoutResID) {
		super.setContentView(layoutResID);
		setStatusBar();
	}
	protected void setStatusBar() {
		StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
	}

	@Override
	protected void onStop() {
		super.onStop();
		MyApplication.getInstance().setShow(false);
	};

	private final static ThreadLocal<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() {
		@Override
		protected SimpleDateFormat initialValue() {
			return new SimpleDateFormat("MM-dd HH:mm");
		}
	};

	protected String getCurrentTime() {
		Date nowTime = new Date();
		String nowTimeStr = dateFormater.get().format(nowTime);
		return nowTimeStr;
	}

	@Override
	public void finish() {
		super.finish();
		MyApplication.getInstance().removeAty(this);
	}

	@Override
	protected void onStart() {
		super.onStart();
    }

	@Override
	protected void onResume() {
		super.onResume();
		MyApplication.getInstance().setShow(true);
		//TCAgent.onResume(this);
	}

	@Override
	protected void onPause() {
		super.onPause();
		//TCAgent.onPause(this);
	}

	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
	}
}
